package scripts;

import java.util.List;

import launcher.Script;

import ui.Display;

import common.CommandExecuter;
import common.Connection;
import common.PropertiesManager;

public class RemoteCommands extends Script {
	public RemoteCommands(Display display, Connection conn, List<String> commandList) {
		super("Comandos en remoto", display, conn);
		setParameter("CommandList", commandList);
	}

	@SuppressWarnings("unchecked")
	public void exec() {
		List<String> commandList = (List<String>)getParameter("CommandList", List.class);
		
		if (commandList.contains("cucust")) {
			display.write("Compilado upstream custom");
			new CommandExecuter(conn, PropertiesManager.getProperty(conn.getEnvironment(), "compileUpstreamCommand"), true);
		}

		if (commandList.contains("cucore")) {
			display.write("Compilado upstream core");
			new CommandExecuter(conn, PropertiesManager.getProperty(conn.getEnvironment(), "compileUpstreamCoreCommand"), true);
		}

		if (commandList.contains("chu")) {
			display.write("Checkmeta en upstream");
			new CommandExecuter(conn, PropertiesManager.getProperty(conn.getEnvironment(), "upstreamcommand"));
		}

		if (commandList.contains("chb")) {
			display.write("Checkmeta en buyer");
			new CommandExecuter(conn, PropertiesManager.getProperty(conn.getEnvironment(), "buyercommand"));
		}

		if (commandList.contains("iu")) {
			display.write("Initdb en upstream");
			new CommandExecuter(conn, PropertiesManager.getProperty(conn.getEnvironment(), "initdbUpstreamCommand"));
		}

		if (commandList.contains("ib")) {
			display.write("Initdb en buyer");
			new CommandExecuter(conn, PropertiesManager.getProperty(conn.getEnvironment(), "initdbBuyerCommand"));
		}
	}
}
